﻿using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace BookDemo.S09.S911
{
    public class Foo
    {
        public class Bar { }
    }
    public class Baz<T> { }
    class S911 : IBookDemo
    {
        public void Main(string[] args)
        {
            Log<Foo>();
            Log<Foo.Bar>();
            Log<Baz<Foo>>();
            Console.Read();

            static void Log<T>()
            {
                new ServiceCollection()
                  .AddLogging(builder => builder.AddConsole())
                  .BuildServiceProvider()
                  .GetRequiredService<ILogger<T>>()
                  .LogInformation($"{typeof(T).FullName}");
                Task.Delay(1).Wait();
            }
        }
    }
}
